package shared.pojo.mission

import shared.Pojo._
import shared.implicits.Implicits._
import shared.tool.DefaultPickle
import upickle.default._

/** Created by yz on 15/5/2023
 */
object Oplsda2DPlot extends Oplsda2DT {

  def pngFileNamePrefixIn = {
    s"OPLSDA_Score_2D"
  }

  def pngFileNamePrefix(idStr: String) = {
    if (idStr.nonBlank) {
      s"${idStr}/${pngFileNamePrefixIn}"
    } else {
      s"${pngFileNamePrefixIn}"
    }
  }

  def configFileName = {
    s"${name}.json"
  }

  case class LayoutData(
                         showSample: String = "F",
                         showEllipse: String = "T",
                         width: String = "5",
                         height: String = "4"
                       )

  object LayoutData {
    implicit val rw = macroRW[LayoutData]
    implicit val defaultRw = DefaultPickle.macroRW[LayoutData]
  }

  case class ColorData(
                        colors: List[String] = List.empty,
                        groups: List[String] = List.empty
                      )

  object ColorData {
    implicit val rw = macroRW[ColorData]
    implicit val defaultRw = DefaultPickle.macroRW[ColorData]
  }

  case class FontData(
                       fontFamily: String = "Times",
                       xFont: String = "9",
                       xTitleFont: String = "12",
                       yFont: String = "8.8",
                       yTitleFont: String = "12",
                       mainTitle: String = "",
                       mainTitleFont: String = "13",
                       legendFont: String = "9",
                       legendTitle: String = "",
                       legendTitleFont: String = "11",
                     )

  object FontData {
    implicit val rw = macroRW[FontData]
    implicit val defaultRw = DefaultPickle.macroRW[FontData]
  }

  case class Request(
                      id: Int = 0,
                      idStr: String = "",
                      kind: String = s"${name}",
                      layout: LayoutData = LayoutData(),
                      color: ColorData = ColorData(),
                      font: FontData = FontData()
                    )

  object Request {
    implicit val rw = macroRW[Request]
    implicit val defaultRw = DefaultPickle.macroRW[Request]
  }

}
